@(title: String, repository: Option[gitbucket.core.service.RepositoryService.RepositoryInfo] = None, highlighterTheme: String = "github-v2")(body: Html)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.plugin.PluginRegistry
@import gitbucket.core.view.helpers
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>@title</title>
    <meta property="og:title" content="@title" />
    <meta property="og:type" content="object" />
    <meta property="og:url" content="@context.request.getRequestURL" />
    @if(repository.isEmpty){
      <meta property="og:image" content="@context.baseUrl/assets/common/images/gitbucket_ogp.png" />
    }
    @repository.map{ r =>
      <meta property="og:image" content="@context.baseUrl/@r.owner/_avatar" />
      @r.repository.description.map{ desc =>
        <meta property="og:description" content="@desc" />
      }
    }
    <link rel="icon" href="@helpers.assets("/common/images/gitbucket.png")" type="image/vnd.microsoft.icon" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="@helpers.assets("/vendors/google-fonts/css/source-sans-pro.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/bootstrap-3.4.1/css/bootstrap.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/octicons-4.4.0/octicons.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/bootstrap-datetimepicker-4.17.44/css/bootstrap-datetimepicker.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/colorpicker/css/bootstrap-colorpicker.min.css")" rel="stylesheet">
    <link href="@helpers.assets(s"/vendors/color-themes-for-google-code-prettify/${highlighterTheme}.min.css")" type="text/css" rel="stylesheet"/>
    <link href="@helpers.assets("/vendors/facebox/facebox.css")" rel="stylesheet"/>
    <link href="@helpers.assets("/vendors/AdminLTE-2.4.2/css/AdminLTE.min.css")" rel="stylesheet">
    <link href="@helpers.assets(s"/vendors/AdminLTE-2.4.2/css/skins/${context.settings.skinName}.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/font-awesome-4.7.0/css/font-awesome.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/jquery-ui/jquery-ui.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/jquery-ui/jquery-ui.structure.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/jquery-ui/jquery-ui.theme.min.css")" rel="stylesheet">
    <link href="@helpers.assets("/common/css/gitbucket.css")" rel="stylesheet">
    <link href="@helpers.assets("/vendors/tipped/tipped.css")" rel="stylesheet">
    <script src="@helpers.assets("/vendors/jquery/jquery-3.5.1.min.js")"></script>
    <script src="@helpers.assets("/vendors/jquery-ui/jquery-ui.min.js")"></script>
    <script src="@helpers.assets("/vendors/dropzone/dropzone.min.js")"></script>
    <script src="@helpers.assets("/common/js/validation.js")"></script>
    <script src="@helpers.assets("/common/js/gitbucket.js")"></script>
    <script src="@helpers.assets("/vendors/bootstrap-3.4.1/js/bootstrap.min.js")"></script>
    <script src="@helpers.assets("/vendors/bootstrap3-typeahead/bootstrap3-typeahead.min.js")"></script>
    <script src="@helpers.assets("/vendors/bootstrap-datetimepicker-4.17.44/js/moment.min.js")"></script>
    <script src="@helpers.assets("/vendors/bootstrap-datetimepicker-4.17.44/js/bootstrap-datetimepicker.min.js")"></script>
    <script src="@helpers.assets("/vendors/colorpicker/js/bootstrap-colorpicker.min.js")"></script>
    <script src="@helpers.assets("/vendors/google-code-prettify/prettify.js")"></script>
    <script src="@helpers.assets("/vendors/elastic/jquery.elastic.source.js")"></script>
    <script src="@helpers.assets("/vendors/facebox/facebox.js")"></script>
    <script src="@helpers.assets("/vendors/jquery-hotkeys/jquery.hotkeys.js")"></script>
    <script src="@helpers.assets("/vendors/jquery-textcomplete-1.8.4/jquery.textcomplete.min.js")"></script>
    <script src="@helpers.assets("/vendors/tipped/tipped.min.js")"></script>
    @repository.map { repository =>
      <meta name="go-import" content="@context.baseUrl.replaceFirst("^https?://", "")/@repository.owner/@repository.name git @repository.httpUrl" />
    }
    <script src="@helpers.assets("/vendors/AdminLTE-2.4.2/js/adminlte.min.js")" type="text/javascript"></script>
    @context.settings.userDefinedCss.map { css =>
      <style type="text/css">@css</style>
    }
  </head>
  <body class="@context.settings.skinName page-load @if(body.toString.contains("menu-item-hover")){sidebar-mini} @if(context.sidebarCollapse){sidebar-collapse}">
    <div class="wrapper">
      <header class="main-header">
        <a href="@context.path/" class="logo">
          <span class="logo-mini"><img src="@helpers.assets("/common/images/gitbucket.svg")" alt="GitBucket" /></span>
          <span class="logo-lg">
            <img src="@helpers.assets("/common/images/gitbucket.svg")" alt="GitBucket" />
            <span class="header-title strong">GitBucket</span>
          </span>
        </a>
        <nav class="navbar navbar-static-top" role="navigation">
          <!-- Sidebar toggle button-->
          @if(body.toString.contains("main-sidebar")) {
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button" title="Toggle navigation">
              <span class="sr-only">Toggle navigation</span>
            </a>
          }
          @if(!(context.loginAccount.isEmpty && !context.settings.basicBehavior.allowAnonymousAccess)) {
            <form id="search" action="@context.path/search" method="GET" class="pc navbar-form navbar-left" role="search">
              <div class="form-group">
                <input type="text" name="query" id="navbar-search-input" class="form-control" placeholder="Find a repository" aria-label="Search"/>
              </div>
            </form>
            <ul class="pc nav navbar-nav">
              <li><a href="@context.path/dashboard/pulls">Pull requests</a></li>
              <li><a href="@context.path/dashboard/issues">Issues</a></li>
              @gitbucket.core.plugin.PluginRegistry().getGlobalMenus.map { menu =>
                @menu(context).map { link =>
                  <li><a href="@context.path/@link.path">@link.label</a></li>
                }
              }
            </ul>
          }
          <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
              @if(context.loginAccount.isDefined){
                <li class="dropdown notifications-menu">
                  <a class="dropdown-toggle menu" data-toggle="dropdown" href="#" aria-label="Create new…">
                    <i class="octicon octicon-plus" style="color: black;"></i><span class="caret" style="color: black; vertical-align: middle;"></span>
                  </a>
                  <ul class="dropdown-menu pull-right" style="width: auto;">
                    <li>
                      <ul class="menu">
                        @if(context.settings.basicBehavior.repositoryOperation.create || context.loginAccount.get.isAdmin){
                          <li><a href="@context.path/new">New repository</a></li>
                        }
                        <li><a href="@context.path/groups/new">New group</a></li>
                      </ul>
                    </li>
                  </ul>
                </li>
                <li class="dropdown notifications-menu">
                  <a class="dropdown-toggle menu" data-toggle="dropdown" href="#" data-toggle="tooltip" data-placement="bottom" title="Signed is as @context.loginAccount.get.userName">
                    @helpers.avatar(context.loginAccount.get.userName, 16)<span class="caret" style="color: black; vertical-align: middle;"></span>
                  </a>
                  <ul class="dropdown-menu pull-right" style="width: auto;">
                    <li>
                      <ul class="menu">
                        <li><a href="@helpers.url(context.loginAccount.get.userName)">Your profile</a></li>
                        <li><a href="@helpers.url(context.loginAccount.get.userName)/_edit">Account settings</a></li>
                        @if(context.loginAccount.get.isAdmin){
                          <li><a href="@context.path/admin/users">System administration</a></li>
                        }
                        <li><a href="@context.path/signout">Sign out</a></li>
                      </ul>
                    </li>
                  </ul>
                </li>
              } else {
                <li>
                  <a href="@context.path/signin?redirect=@helpers.urlEncode(context.currentPath)" class="pull-right" id="signin">Sign in</a>
                </li>
              }
            </ul>
          </div>
        </nav>
      </header>
      @body
    </div>
    <script>
      $(function(){
        @*
        $('#search').submit(function(){
          return $.trim($(this).find('input[name=query]').val()) != '';
        });
        *@
        @if(body.toString.contains("main-sidebar")){
          $(".sidebar-toggle").on('click', function(e){
            $.post('@context.path/sidebar-collapse', { collapse: !$('body').hasClass('sidebar-collapse') });
          });
        }
      });
    </script>
    @PluginRegistry().getJavaScript(context.request.getRequestURI).map { script =>
      <script>
        @Html(script)
      </script>
    }
  </body>
</html>
